﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class View_Transfers : _View_Transfers
    {
        public static View_Transfers GetByID(int id)
        {
            View_Transfers tf = new View_Transfers();
            tf.Where.ID.Value = id;
            tf.Query.Load();

            return tf;
        }

        public static View_Transfers GetRelatedTransfers(int branchID, DateTime from, DateTime to)
        {
            View_Transfers tf = new View_Transfers();
            tf.Query.OpenParenthesis();
            tf.Where.FromBranchID.Value = branchID;
            tf.Where.FromBranchID.Conjuction = MyGeneration.dOOdads.WhereParameter.Conj.Or;
            tf.Where.ToBranchID.Value = branchID;
            tf.Where.ToBranchID.Conjuction = MyGeneration.dOOdads.WhereParameter.Conj.Or;
            tf.Query.CloseParenthesis();
            tf.Where.TransferedDate.BetweenEndValue = to;
            tf.Where.TransferedDate.BetweenBeginValue = from;
            tf.Where.TransferedDate.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Between;
            tf.Query.Load();

            return tf;
        }

        public static View_Transfers GetRelatedTransfers(int branchID)
        {
            View_Transfers tf = new View_Transfers();
            tf.Where.FromBranchID.Value = branchID;
            tf.Where.FromBranchID.Conjuction = MyGeneration.dOOdads.WhereParameter.Conj.Or;
            tf.Where.ToBranchID.Value = branchID;
            tf.Where.ToBranchID.Conjuction = MyGeneration.dOOdads.WhereParameter.Conj.Or;
            tf.Query.Load();

            return tf;
        }
    }
}
